package com.itheima.itheima_health.service.Impl;

import com.itheima.itheima_health.service.ReportService;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

@Service
public class ReportServiceImpl implements ReportService {
    @Override
    public void exportBusinessDate(HttpServletResponse response) throws IOException {
        InputStream in = this.getClass().getClassLoader().getResourceAsStream("template/ordersetting_template.xlsx");

        XSSFWorkbook excel = new XSSFWorkbook(in);

        //3.通过输出流将Rxcel文件下载到客服端浏览器
        ServletOutputStream out = response.getOutputStream();
        excel.write(out);

        //关闭资源
        out.close();
        excel.close();
    }
}
